﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace GC_RF.Domain.Extensions
{
	public static class DirectoryInfoEx
	{
		public static IEnumerable<string> GetFilesByExtensions(this DirectoryInfo directoryInfo,
			IEnumerable<string> fileExtensions)
		{
			if (directoryInfo == null || fileExtensions == null) return null;

			var files = directoryInfo.GetFiles();

			return files
				.Where(f => fileExtensions.Contains(f.Extension, StringComparer.OrdinalIgnoreCase))
				.Select(f => f.Name)
				.ToList();
		}
	}
}
